#ifndef _RADIX_H
#define _RADIX_H

#include <stdint.h>
#include <pthread.h>

#define MAXRADIXDEEP 0x00000020

struct radixNode;

struct radixConfig{
    int32_t  withLock ;
    int32_t  treeDeep ;
    int32_t  maxLeafNode  ;
    int32_t  lruPercent   ;
    int32_t  maxDeep      ;
};

struct radixNode{
    void   *data;
    struct radixNode * left  ;
    struct radixNode * right ;
    int16_t  nodeDeep        ;
    int16_t  uniqueFlag      ;
    uint32_t viewCount       ;
};


struct radixTree{
    struct radixNode    *root   ;
    uint32_t            numNode ;
    pthread_mutex_t     *lock   ;
    struct radixConfig  *rconfig;
};


int32_t radixCreate(radixTree * _tree, radixConfig * _rconfig);

int32_t radixDestory(radixTree * _t);

int32_t radixInsert(radixTree * _t, uint32_t _key, void * _data, uint32_t _dataLength);

int32_t radixDel(radixTree * _t, uint32_t _key);

int32_t radixLRU(radixTree * _t, int32_t  lruPercent);

int32_t radixInfo(radixTree * _t);

#endif